function changeCode(obj) {
    // let src = document.getElementsByClassName("imgCode")[0].src;
    // document.getElementsByClassName("imgCode")[0].src = src + "?aa" + Math.random();
    // console.log(src)
    $(obj).attr("src", "/code?aa" + Math.random());
}

function login() {
    let data = {
        username: $("#username").val(),
        password: $("#password").val(),
        code: $("#code").val()
    };

    $.ajax({
        url: '/login',//访问后台servlet的地址
        data: data,
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.result == "登录成功") {
                sessionStorage.setItem("username", $("#username").val());
                // localStorage.setItem("username", data.username);
                window.location.href = "/html/manage.html";
                // window.open("url","");
            } else {
                // if(data.result==0){
                //     alert("")
                // }else if(data.result==-1){
                //     alert("yanzm")
                // }
                alert(data.result);
            }
        }
    })

}

function goRegister() {
    window.location.href = "/html/register.html";
}